﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LeHouse.Server.Dto;
namespace LeHouse.Server.Dal
{
    /// <summary>
    /// 抵押物区位状况
    /// </summary>
    public class Collateral_ZoneDAL : GenericBaseDAL<Collateral_Zone>
    {
        /// <summary>
        /// 根据报告号去查询抵押物区位有该条记录
        /// </summary>
        /// <param name="P_ReportNumber"></param>
        /// <returns></returns>
        public int count(string P_ReportNumber)
        {   
            int C_projectcount;
            string sql = @"select count(Z_trafficID) from t_Zone  where P_ReportNumber=@P_ReportNumber ";
            using (var cnn = DbConnection)
            {
                using (var cmd = cnn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    var p = cmd.CreateParameter();
                    p.ParameterName = "@P_ReportNumber";
                    p.Value = P_ReportNumber;
                    cmd.Parameters.Add(p);
                    C_projectcount = Convert.ToInt32(cmd.ExecuteScalar());
                }
                return C_projectcount;
            }
        }

        /// <summary>
        /// 根据报告号去查询抵押物区位的信息
        /// </summary>
        /// <param name="P_ReportNumber"></param>
        /// <returns></returns>
        public Collateral_Zone Facilitybyid(string P_ReportNumber)
        {
            Collateral_Zone munity = new Collateral_Zone();
            string sql = @"select * from t_Zone  where P_ReportNumber=@P_ReportNumber ";
            using (var cnn = DbConnection)
            {
                using (var cmd = cnn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    var p = cmd.CreateParameter();
                    p.ParameterName = "@P_ReportNumber";
                    p.Value = P_ReportNumber;
                    cmd.Parameters.Add(p);
                    var reader = cmd.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            //munity.P_ReportNumber = reader["P_ReportNumber"].ToString();
                            //munity.Z_master = reader["Z_master"].ToString();
                            //munity.Z_south = reader["Z_south"].ToString();
                            //munity.Z_western = reader["Z_western"].ToString();
                            //munity.Z_north           =reader["Z_north"].ToString();
                            //munity.Z_trafficID       =Convert.ToInt32( reader["Z_trafficID"]);
                            //munity.Z_traffic         = reader["Z_traffic"].ToString();
                            //munity.Z_natureID        =Convert.ToInt32( reader["Z_natureID"]);
                            //munity.Z_nature          =reader["Z_nature"].ToString();
                            //munity.Z_dwellingID      =Convert.ToInt32( reader["Z_dwellingID"]);
                            //munity.Z_dwelling        =reader["Z_dwelling"].ToString();
                            //munity.Z_infrastructureID=Convert.ToInt32( reader["Z_infrastructureID"]);
                            //munity.Z_supportingID    =Convert.ToInt32( reader["Z_supportingID"]);
                            //munity.Z_explain         =reader["Z_explain"].ToString();
                            //munity.Z_infrastructure = reader["Z_infrastructure"].ToString();
                            //munity.Z_surroundID = Convert.ToInt32( reader["Z_surroundID"]);

                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
                return munity;
            }
        }

    }
}
